#ifndef AIPLAYER_H
#define AIPLAYER_H

#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <cassert>

//chess stuff
#include "ChessType.h"
#include "ChessBoard.h"
#include "ChessPlayer.h"
#include "ChessManMoveTable.h"

//tool stuff
#include "Logger.h"
#include "ConstValueUtil.h"

//message stuff
#include "GlobalMessage.h"

//boost stuff
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>

typedef float BoardScoreType;

class AiPlayer : public ChessPlayer
{
public:
	AiPlayer(void);
	virtual ~AiPlayer(void);

	virtual void		CalculateAi();
	
	//set the search depth,use for adjust ai level,default is 4
	void				SetMaxDepth(int depth);

private:
	BoardScoreType		AlphaBetaPruning(ChessBoard& board,float alpha,float beta,int depth);
	BoardScoreType		GetScoreOfChessBoard(const ChessBoard& board);

//evaluation function stuff
private:
	BoardScoreType		GetMaterialScore(const ChessBoard& board);
	BoardScoreType		GetSpaceAndThreatScore(const ChessBoard& board);

private:
	int					m_iMaxDepth;

	static BoardScoreType materialScoreTab[7];
	static short whiteScope[8][8];
	static short blackScope[8][8];
};

#endif
